﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/MasterPage.master" AutoEventWireup="true"
    CodeFile="ProductDetails.aspx.cs" Inherits="Pages_Store_ProductDetails" MaintainScrollPositionOnPostback="true" %>

<%--<%@ Register Src="../WebControls/AlsoPurchased.ascx" TagName="AlsoPurchased" TagPrefix="fns" %>--%>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <%-- <div class="center_title_bar">
        <asp:Label ID="ProductName" runat="server" Text=""></asp:Label>
    </div>--%>
    <center>
        <br />
        <br />
        <asp:Label ID="Msg" runat="server" Font-Size="11px" Text=""></asp:Label></center>
    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT Products.price, Products.name, Brands.brand_name, Product_Categories.category_name, Products.old_price, Products.code, Products.views, Products.rating, Products.supplier_stock, Products.shop_stock, Products.is_active FROM Products INNER JOIN Brands ON Products.BrandID = Brands.ID INNER JOIN Product_Categories ON Products.CategoryID = Product_Categories.CategoryID AND Products.ID = @ID WHERE (Products.deleted = 0)">
        <SelectParameters>
            <asp:RouteParameter Name="ID" RouteKey="id" />
        </SelectParameters>
    </asp:SqlDataSource>
    <!-- Nume Produs -->
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            <div class="center_title_bar">
                <%#Eval("name") %></div>
        </ItemTemplate>
    </asp:Repeater>
    <!-- Rating Bar -->
    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>
            <div class="center_rating_bar">
                <asp:Label ID="Label18" runat="server" Text="Voteaza  : "></asp:Label>
                <asp:LinkButton ID="HyperLink0" runat="server" OnClick="Image_Url0">
                    <asp:Image ID="Imagine_0" ImageUrl="~/Content/SiteImages/rating0.png" runat="server" />
                </asp:LinkButton>
                <asp:LinkButton ID="HyperLink1" runat="server" OnClick="Image_Url1">
                    <asp:Image ID="Image5" ImageUrl="~/Content/SiteImages/rating1.png" runat="server" />
                </asp:LinkButton>
                <asp:LinkButton ID="HyperLink2" runat="server" OnClick="Image_Url2">
                    <asp:Image ID="Image6" ImageUrl="~/Content/SiteImages/rating2.png" runat="server" />
                </asp:LinkButton>
                <asp:LinkButton ID="HyperLink3" runat="server" OnClick="Image_Url3">
                    <asp:Image ID="Image7" ImageUrl="~/Content/SiteImages/rating3.png" runat="server" />
                </asp:LinkButton>
                <asp:LinkButton ID="HyperLink4" runat="server" OnClick="Image_Url4">
                    <asp:Image ID="Image8" ImageUrl="~/Content/SiteImages/rating4.png" runat="server" />
                </asp:LinkButton>
            </div>
            <%--</ContentTemplate>
  </asp:UpdatePanel>--%>
            <!-- end rating bar -->
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:StoreDBConnectionString %>"
                SelectCommand="SELECT TOP 1 [name] FROM [Products] WHERE @ID = ID">
                <SelectParameters>
                    <asp:RouteParameter DefaultValue="0" Name="ID" RouteKey="id" />
                </SelectParameters>
            </asp:SqlDataSource>
            <!-- Detaliere Produs -->
            <div class="prod_box_big">
                <div class="top_prod_box_big">
                </div>
                <div class="center_prod_box_big">
                    <div class="product_img_big">
                        <asp:Repeater ID="Repeater3" runat="server" DataSourceID="SqlDataSource3">
                            <ItemTemplate>
                                <asp:Image ID="Image2" runat="server" ImageUrl='<%#Eval("image_url") %>' Height="100px"
                                    Width="100px" />
                            </ItemTemplate>
                        </asp:Repeater>
                        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:StoreDBConnectionString %>"
                            SelectCommand="SELECT image_url FROM Images WHERE (size_type LIKE 'small') AND (ProductID = @ID)">
                            <SelectParameters>
                                <asp:RouteParameter Name="ID" RouteKey="id" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <div class="thumbs">
                            <asp:Repeater ID="Repeater2" runat="server" DataSourceID="SqlDataSource2">
                                <ItemTemplate>
                                    <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("image_url") %>' Height="35px"
                                        Width="35px" />
                                </ItemTemplate>
                            </asp:Repeater>
                            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:StoreDBConnectionString %>"
                                SelectCommand="SELECT image_url FROM Images WHERE (ProductID = @ID)">
                                <SelectParameters>
                                    <asp:RouteParameter Name="ID" RouteKey="id" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                        </div>
                        <asp:LinkButton ID="LinkButton3" runat="server" onclick="LinkButton3_Click" CssClass="addtocart"> Cumpara</asp:LinkButton>
                        
                    </div>
                    <div class="details_big_box">
                        <asp:Repeater ID="Repeater4" runat="server" DataSourceID="SqlDataSource4" ClientIDMode="Inherit">
                            <ItemTemplate>
                                <table width="250px">
                                    <tr class="product_title_big">
                                        <td colspan="2" align="center">
                                            <asp:Label ID="ProductName" runat="server" Text='<%#Eval("name") %>'></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <br />
                                        </td>
                                        <td>
                                            <br />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Label2" runat="server" Text="Producator "></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="BrandName" runat="server" Text='<%#Eval("brand_name") %>' Font-Bold="True"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Label3" runat="server" Text="Categorie "></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="Label4" runat="server" Text='<%#Eval("category_name") %>' Font-Bold="True"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Label5" runat="server" Text="Cod produs "></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="Label6" runat="server" Text='<%#Eval("code") %>' Font-Bold="True"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Label7" runat="server" Text="Vizualizari "></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="Label8" runat="server" Text='<%#Eval("views") %>' Font-Bold="True"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Label9" runat="server" Text="Rating "></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Image ID="Image3" runat="server" ImageUrl='<%#Page.ResolveUrl("~/Content/SiteImages/rating"+Eval("rating")+".png") %>' />
                                            <asp:Label ID="Label10" runat="server" Text='<%#"(" + (Convert.ToInt32(Eval("rating")) + 1) + " din 5)"%>'
                                                Font-Bold="True"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="Label13" runat="server" Text="Disponibilitate "></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="Label14" Font-Bold="True" runat="server" Text='<%# disponibilitate_status(Convert.ToBoolean(Eval("is_active")), Convert.ToInt32(Eval("shop_stock")), Convert.ToInt32(Eval("supplier_stock")))%>'></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="prod_price_big">
                                            <asp:Label ID="Label12" runat="server" Text="Pret"></asp:Label>
                                        </td>
                                        <td class="prod_price_big">
                                            <asp:Label ID="Label15" runat="server" class="reduce" Text='<%# show_old_price(Convert.ToString(Eval("old_price")))%>'></asp:Label>
                                            <asp:Label ID="Label16" runat="server" class="price" Text='<%# String.Format("{0:0,0.##}", Eval("price")) + " RON"%>'></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:Repeater>
                    </div>
                </div>
                <div class="bottom_prod_box_big">
                </div>
            </div>
            <%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
      <ContentTemplate>--%>
            <div class="prod_box_big">
                <div>
                    <table style="border-spacing: 0px; padding-left: 10px;">
                        <tr>
                            <td>
                                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">
                                    <div runat="server" id="descriere_button_1" class="title_box_vizualizare_produs">
                                        <asp:Label ID="Label1" runat="server" Text="Descriere" ForeColor="White"></asp:Label>
                                    </div>
                                </asp:LinkButton>
                            </td>
                            <td>
                                <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">
                                    <div runat="server" id="descriere_button_2" class="title_box_vizualizare_produs">
                                        <asp:Label ID="Label17" runat="server" Text="Comentarii" ForeColor="White"></asp:Label>
                                    </div>
                                </asp:LinkButton>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="top_prod_box_big">
                </div>
                <div class="center_prod_box_big">
                    <asp:Panel ID="Descriere_produs" runat="server">
                                
                                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource6">
                                    <Columns>
                                        <asp:BoundField DataField="atribut_value" HeaderText="atribut_value" SortExpression="atribut_value" />
                                        <asp:BoundField DataField="atribute_name" HeaderText="atribute_name" SortExpression="atribute_name" />
                                    </Columns>
                                </asp:GridView>

                        <asp:SqlDataSource ID="SqlDataSource6" runat="server" ConnectionString="<%$ ConnectionStrings:StoreDBConnectionString %>"
                            SelectCommand="SELECT Atribute_Value.atribut_value, Atribute_Type.atribute_name, Atribut_Category.atribut_category_name FROM Product_Atributes INNER JOIN Atribut_Category ON Product_Atributes.ID = Atribut_Category.ID INNER JOIN Atribute_Type ON Atribut_Category.ID = Atribute_Type.AtributCategoryID INNER JOIN Atribute_Value ON Product_Atributes.AtributID = Atribute_Value.ID AND Atribute_Type.ID = Atribute_Value.AtributeTypeID AND Product_Atributes.ProductID = @id">
                            <SelectParameters>
                                <asp:RouteParameter Name="id" RouteKey="id" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <%--<asp:SqlDataSource ID="SqlDataSource7" runat="server" ConnectionString="<%$ ConnectionStrings:StoreDBConnectionString %>"
                            SelectCommand="SELECT Atribut_Category.atribut_category_name, Atribut_Category.ID FROM Atribut_Category INNER JOIN Product_Atributes ON Atribut_Category.ID = Product_Atributes.ID WHERE (Product_Atributes.ProductID = @id)">
                            <SelectParameters>
                                <asp:RouteParameter Name="id" RouteKey="id" />
                            </SelectParameters>
                        </asp:SqlDataSource>--%>
                    </asp:Panel>
                    <asp:Panel ID="Comentarii_produs" runat="server">
                        <asp:Repeater ID="Repeater5" runat="server" DataSourceID="SqlDataSource5">
                            <ItemTemplate>
                                <table align="center">
                                    <tr>
                                        <td>
                                            <table>
                                                <tr>
                                                    <td>
                                                        <asp:Image ID="Image4" runat="server" ImageUrl="~/Content/UsersImages/avatar.jpg"
                                                            class="Avatar-Persoana" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label19" runat="server" Style="background-color: #CCF;" WordWrap="true"
                                                            Text='<%#Eval("UserName") %>' ReadOnly="True"></asp:Label>
                                                        <%--<asp:Label ID="Label18" runat="server" Text='<%#Eval("UserName")%>' ></asp:Label>--%>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td>
                                            <table style="background-color: #CCF;">
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label22" Width="400px" TextMode="MultiLine" runat="server" WordWrap="true"
                                                            Text='<%# Eval("comment_title") + " | user:" + Eval("UserName") %>' ReadOnly="True"
                                                            MaxLength="1000" Rows="3"></asp:Label>
                                                        <%--<asp:Label ID="Label19" runat="server" Width="400px" Text='<%#Eval("comment_title")%>' ></asp:Label>--%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <asp:Label ID="Label20" Width="400px" TextMode="MultiLine" runat="server" WordWrap="true"
                                                            Text='<%#Eval("comment_body") %>' ReadOnly="True" MaxLength="1000" Rows="3"></asp:Label>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </asp:Repeater>
                        <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:StoreDBConnectionString %>"
                            SelectCommand="SELECT aspnet_Users.UserName, Comments.comment_title, Comments.comment_body FROM Comments INNER JOIN aspnet_Users ON Comments.UserID = aspnet_Users.UserId INNER JOIN Product_Comments ON Comments.ID = Product_Comments.CommentID WHERE (Product_Comments.ProductID = @id)">
                            <SelectParameters>
                                <asp:RouteParameter Name="id" RouteKey="id" />
                            </SelectParameters>
                        </asp:SqlDataSource>
                        <table align="center">
                            <tr>
                                <td colspan="3">
                                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="comment"
                                        ForeColor="Red" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label11" runat="server" Text="Titlu" Width="90px"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="Subject_tb" runat="server" Width="358px" ValidationGroup="comment"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ValidationGroup="comment"
                                        runat="server" ErrorMessage="Introduce titlu!" ControlToValidate="Subject_tb"
                                        ForeColor="Red">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label21" runat="server" Text="Mesaj" Width="90px"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="Message_tb" runat="server" Width="358px" ValidationGroup="comment"
                                        MaxLength="250"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ValidationGroup="comment"
                                        ErrorMessage="Introduce mesaj!" ControlToValidate="Message_tb" ForeColor="Red">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:Button ID="Button1" runat="server" Text="Posteaza mesaj" ValidationGroup="comment"
                                        OnClick="Button1_Click" />
                                </td>
                            </tr>
                        </table>
                    </asp:Panel>
                </div>
                <div class="bottom_prod_box_big">
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
    <%-- <fns:AlsoPurchased ID="AlsoPurchased" runat="server" ProductID='<%$ RouteValue:id %>' />--%>
    <asp:PlaceHolder ID="AlsoPurchased" runat="server"></asp:PlaceHolder>
</asp:Content>
